var init = function() {
    
    var navhis= new OpenLayers.Control.NavigationHistory();
    var scale = new OpenLayers.Control.Scale({
        geodesic: true
    });
    var map = new OpenLayers.Map( 'map', {
        maxExtent: [-180, -90, 180, 90],
        projection: new OpenLayers.Projection("EPSG:4326"),
        //maxExtent: new OpenLayers.Bounds(-65.5442, -36.148, -54.4558, -27.0391),
        // restrictedExtent: [-63.4154, -34.8242, -57.9377, -27.6729],
        //maxResolution: 1000,
        units:"degrees",
        controls: [
        new OpenLayers.Control.Navigation(),
        new OpenLayers.Control.Attribution(),
        new OpenLayers.Control.PanZoomBar(),
        new OpenLayers.Control.LayerSwitcher({
            'ascending':false
        }),
        navhis,
        new OpenLayers.Control.ScaleLine({
            geodesic: true
        }),
        new OpenLayers.Control.MousePosition({
            separator: ' | ',
            numDigits: 4,
            emptyString: 'Fuera del mapa'
        }),
       
        scale,
        new OpenLayers.Control.KeyboardDefaults()
        ],
        numZoomLevels: 20,
        allOverlays: true
        
    } );
    var panel = new OpenLayers.Control.Panel(
    {
        div: document.getElementById("panel")
    }
    );
    panel.addControls([navhis.next, navhis.previous ]);
    map.addControl(panel);

    var catastro_regiones_EPSG_4326_slayer = new OpenLayers.Layer.WMS( "catastro_regiones-EPSG:4326 (singleTile)",
        "http://www.idesf.santafe.gov.ar/cgi-bin/idesf?",{
            layers: 'catastro_regiones'
            
        },
        {
            isBaseLayer:false,
            ratio:1,
            buffer:0,
            singleTile:true,
            maxResolution:0.01098632812500000000,
            format:"image/png",
            projection: new OpenLayers.Projection("EPSG:4326".toUpperCase())
        }
        );
    map.addLayer(catastro_regiones_EPSG_4326_slayer);
    var catastro_regiones_toponimia_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "catastro_regiones_toponimia-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'catastro_regiones_toponimia',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
   
    var cdz_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "cdz-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'cdz',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
 

   
    
    var scit_manz_pcia_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "scit_manz_pcia-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'scit_manz_pcia',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );


    var salud_centros_toponimia_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "salud_centros_toponimia-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'salud_centros_toponimia',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
   

    
    var ejesipec_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "ejesipec-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'ejesipec',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
  
    var catastro_regiones_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "catastro_regiones-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'catastro_regiones',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/jpeg',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
    

    var scit_parcelas_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "scit_parcelas-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'scit_parcelas',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );



    var localidades_point_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "localidades_point-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'localidades_point',
        matrixSet: 'EPSG:4326',
        visibility:false,
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
    
    var scit_parcelas_toponimia_EPSG_4326_wmts_layer = new OpenLayers.Layer.WMTS({
        name: "scit_parcelas_toponimia-EPSG:4326-WMTS",
        url: "http://localhost/map.fcgi/wmts/",
        layer: 'scit_parcelas_toponimia',
        matrixSet: 'EPSG:4326',
        format: 'image/png',
        style: 'default',
        gutter:0,
        buffer:0,
        isBaseLayer:false,
        transitionEffect:'resize',
        resolutions:[0.01098632812500000000,0.00549316406250000000,0.00274658203125000000,0.00137329101562500000,0.00068664550781250000,0.00034332275390625000,0.00017166137695312500,0.00008583068847656250,0.00004291534423828120,0.00002145767211914060,0.00001072883605957030,0.00000536441802978516],
        zoomOffset:0,
        units:"dd",
        maxExtent: new OpenLayers.Bounds(-180.000000,-90.000000,180.000000,90.000000),
        projection: new OpenLayers.Projection("EPSG:4326".toUpperCase()),
        sphericalMercator: false
    }
    );
    map.addLayer(catastro_regiones_EPSG_4326_wmts_layer);
    map.addLayer(cdz_EPSG_4326_wmts_layer);
    map.addLayer(scit_parcelas_EPSG_4326_wmts_layer);
    map.addLayer(localidades_point_EPSG_4326_wmts_layer);
    map.addLayer(catastro_regiones_toponimia_EPSG_4326_wmts_layer);
    map.addLayer(ejesipec_EPSG_4326_wmts_layer);
    map.addLayer(salud_centros_toponimia_EPSG_4326_wmts_layer)
    map.addLayer(scit_parcelas_toponimia_EPSG_4326_wmts_layer);
    map.addLayer(scit_manz_pcia_EPSG_4326_wmts_layer)
     
    
    
    var panel = new OpenLayers.Control.Panel({
        defaultControl: new OpenLayers.Control.ZoomPanel(),
        controls: [ new OpenLayers.Control.ZoomPanel()]
       
    });
    map.events.register("zoomend", map, function(e){
        updateScale(e);
    });
        
    if(!map.getCenter())
        map.zoomToMaxExtent();
    map.setCenter(new OpenLayers.LonLat(-60,-31));
    
//map.addControl(new new OpenLayers.Control.Scale('scale'));
//    map.addControl(new OpenLayers.Control.KeyboardDefaults());
};
function updateScale(e) {
    $('#currentScale').val(e.object.getScale());
    $('#currentZoomLevel').val(e.object.getZoom());
}
               

window.addEventListener("DOMContentLoaded", init )